/////////////////////////////////////////////////////////////////////////////////////////////
// Filename: InputOwnedStates.cpp
// (c) Dave Ottley, 2012. All rights reserved.
/////////////////////////////////////////////////////////////////////////////////////////////

///////////////////////////
//		INCLUDES
///////////////////////////
#include <assert.h>

///////////////////////////
//		MY INCLUDES
///////////////////////////
#include "Constants.h"
#include "InputClass.h"
#include "InputOwnedStates.h"
#include "InputMessages.h"
#include "ApplicationMessages.h"
#include "MessageDispatcher.h"
#include "SubsystemID.h"
#include "GameTimer.h"

//------------------------------------------------------methods for InputNormalState
InputNormalState * InputNormalState::GetInstance()
{
	static InputNormalState theOne;

	return &theOne;
}

void InputNormalState::Enter( InputClass * inputSubsystem)
{
	//...
}

void InputNormalState::Execute( InputClass * inputSubsystem)
{
	   
	// Only for self updating (sentient) entities

}

void InputNormalState::Exit( InputClass * inputSubsystem)
{
	//...
}

bool InputNormalState::OnMessage( InputClass * inputSubsystem, const Telegram& msg)
{
	switch(msg.Msg)
	{
	case InputMsg::MouseDown:
		{
			
			break;
		}
		
	case InputMsg::MouseUp:
		{
			int* pMouseX = (int*) msg.ExtraInfo;
			int* pMouseY = pMouseX + INT_BYTES;
			break;
		}

	case InputMsg::MouseMove:
		{
			int* pMouseX = (int*) msg.ExtraInfo;
			int* pMouseY = pMouseX + INT_BYTES;
			break;
		}

	case InputMsg::KeyDown:
		{

			break;
		}

	default:
		assert( false && "<InputNormalState::OnMessage> Undefined Input Message Delivered. Cannot Handle.");
		return false;

	} // switch(msg)

	if(timeElapsed >= INPUT_DELAY_IN_MILISECONDS)
		Dispatch->DispatchMessage(SEND_MSG_IMMEDIATELY, SubsystemID::INPUT, SubsystemID::APPLICATION, ApplicationMsg::InputBatch);
	return true;
	
}

//------------------------------------------------------methods for InputGlobalState
InputGlobalState * InputGlobalState::GetInstance()
{
	static InputGlobalState theOne;

	return &theOne;
}

void InputGlobalState::Enter( InputClass * inputSubsystem)
{
	//...
}

void InputGlobalState::Execute( InputClass * inputSubsystem)
{
	   
	//...

}

void InputGlobalState::Exit( InputClass * inputSubsystem)
{
	//...
}

bool InputGlobalState::OnMessage( InputClass * inputSubsystem, const Telegram& msg)
{
	//...
	return true;
}

//------------------------------------------------------methods for InputFrozenState
InputFrozenState * InputFrozenState::GetInstance()
{
	static InputFrozenState theOne;

	return &theOne;
}

void InputFrozenState::Enter( InputClass * inputSubsystem)
{
	//...
}

void InputFrozenState::Execute( InputClass * inputSubsystem)
{
	   
	//...

}

void InputFrozenState::Exit( InputClass * inputSubsystem)
{
	//...
}

bool InputFrozenState::OnMessage( InputClass * inputSubsystem, const Telegram& msg)
{
	//...
	return true;
}